<%--
  Created by IntelliJ IDEA.
  User: HP
  Date: 2021-09-15
  Time: 18:19
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<style type="text/css">
    table
    {
        border-collapse: collapse;
        margin: 0 auto;
        text-align: center;
    }
    table td, table th
    {
        border: 1px solid #cad9ea;
        color: #666;
        height: 30px;
    }
    table thead th
    {
        background-color: #CCE8EB;
        width: 100px;
    }
    table tr:nth-child(odd)
    {
        background: #fff;
    }
    table tr:nth-child(even)
    {
        background: #F5FAFA;
    }
    </style>
<div class="col-md-9">



    <div class="data_list">
        <div class="data_list_title"><span class="glyphicon glyphicon-edit"></span>&nbsp;个人中心 </div>
        <div class="container-fluid">
            <div class="row" style="padding-top: 20px;">
                <div class="col-md-8">
                    <form class="form-horizontal" method="post" action="user" enctype="multipart/form-data" >
                        <div class="form-group">
                            <input type="hidden" name="actionName" value="updateUser">
                            <label for="nickName" class="col-sm-2 control-label">昵称:</label>
                            <div class="col-sm-3">
                                <input class="form-control" name="nick" id="nickName" placeholder="昵称" value="${user.nick}">
                            </div>
                            <label for="img" class="col-sm-2 control-label">头像:</label>
                            <div class="col-sm-5">
                                <input type="file" id="img" name="img">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="motto" class="col-sm-2 control-label">签名:</label>
                            <div class="col-sm-10">
                                <textarea class="form-control" name="motto" id="motto" rows="3">${user.motto}</textarea>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-offset-2 col-sm-10">
                                <button type="submit" id="btn" class="btn btn-success" onclick="return updateUser();">修改</button>&nbsp;&nbsp;
                                <span style="color:red; font-size: 12px;" id="msg"></span>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="col-md-4"><img style="width:240px;height:180px" src="user?actionName=userHead&imageName=${user.head}"></div>
            </div>
        </div>
    </div>


<%--    <div class="data_list">--%>
<%--        <div><h1>身体评估状态：</h1></div>--%>
<%--    <div><label style="font-size: 20px">身高：</label> <label id="shengao" style="font-size: 20px">${health.height} </label></div>--%>
<%--    <div><label style="font-size: 20px">体重：</label> <label id="tizhong" style="font-size: 20px" >${health.weight}</label></div>--%>
<%--    <div> <label style="font-size: 20px">年龄：</label> <label id="nianling" style="font-size: 20px">${health.age}</label></div>--%>
<%--    <div><label style="font-size: 20px">性别：</label> <label id="xingbie" style="font-size: 20px"><c:if test="${health.gender==1}">男</c:if><c:if test="${health.gender==0}">女</c:if></label></div>--%>
<%--        <div><label style="font-size: 20px">BMI：</label> <label id="bmi" style="font-size: 20px">${bmi} </label></div>--%>
<%--        <div><label style="font-size: 20px">体重状态：</label> <label id="bmix" style="font-size: 20px">${bmix} </label></div>--%>
<%--        <div><label style="font-size: 20px">高血压的可能性：</label> <label id="xue" style="font-size: 20px"><c:if test="${xueTotal==0}">几乎没有</c:if><c:if test="${xueTotal==1}">低</c:if><c:if test="${xueTotal==2}">中</c:if><c:if test="${xueTotal==3}">高</c:if></label></div>--%>
<%--        <div><label style="font-size: 20px">心脏病的可能性：</label> <label id="xin" style="font-size: 20px"><c:if test="${xinTotal==0}">几乎没有</c:if><c:if test="${xinTotal==1}">低</c:if><c:if test="${xinTotal==2}">中</c:if><c:if test="${xinTotal==3}">高</c:if></label></div>--%>
<%--        <div><label style="font-size: 20px">抑郁症的程度：</label> <label id="yi" style="font-size: 20px"><c:if test="${yiTotal==0}">正常</c:if><c:if test="${yiTotal==1}">轻度抑郁</c:if><c:if test="${yiTotal==2}">中度抑郁</c:if><c:if test="${yiTotal==3}">重度抑郁</c:if></label></div>--%>
<%--        <div><label style="font-size: 20px">焦虑症的可能性：</label> <label id="jiao" style="font-size: 20px"><c:if test="${jiaoTotal==0}">几乎没有</c:if><c:if test="${jiaoTotal==1}">偏低</c:if><c:if test="${jiaoTotal==2}">偏高</c:if></label></div>--%>
<%--    </div>--%>
    <div class="data_list">

        <table width="90%" class="table">
            <caption>
                <div><h2>身体评估状态</h2></div>
            </caption>
            <tr>
                <div><td><label style="font-size: 20px">身高：</label></td><td> <label id="shengao" style="font-size: 20px">${health.height} </label></td></div>
            </tr>
            <tr>
                <div><td><label style="font-size: 20px">体重：</label></td><td> <label id="tizhong" style="font-size: 20px" >${health.weight}</label></td></div>
            </tr>
            <div><td> <label style="font-size: 20px">年龄：</label></td><td> <label id="nianling" style="font-size: 20px">${health.age}</label></td></div>
            </tr>
            <tr>
                <div><td><label style="font-size: 20px">性别：</label></td><td> <label id="xingbie" style="font-size: 20px"><c:if test="${health.gender==1}">男</c:if><c:if test="${health.gender==0}">女</c:if></label></td></div>
            </tr>
            <tr>
                <div><td><label style="font-size: 20px">BMI：</label></td><td> <label id="bmi" style="font-size: 20px">${bmi} </label></td></div>
            </tr>
            <div><td><label style="font-size: 20px">体重状态：</label></td><td> <label id="bmix" style="font-size: 20px">${bmix} </label></td></div>
            <tr>
            </tr>
            <tr>
                <div><td><label style="font-size: 20px">高血压的可能性：</label></td><td> <label id="xue" style="font-size: 20px"><c:if test="${xueTotal==0}">几乎没有</c:if><c:if test="${xueTotal==1}">低</c:if><c:if test="${xueTotal==2}">中</c:if><c:if test="${xueTotal==3}">高</c:if></label></td></div>
            </tr>
            <tr>
                <div><td><label style="font-size: 20px">心脏病的可能性：</label></td><td> <label id="xin" style="font-size: 20px"><c:if test="${xinTotal==0}">几乎没有</c:if><c:if test="${xinTotal==1}">低</c:if><c:if test="${xinTotal==2}">中</c:if><c:if test="${xinTotal==3}">高</c:if></label></td></div>
            </tr>
            <tr>
                <div><td><label style="font-size: 20px">抑郁症的程度：</label></td><td> <label id="yi" style="font-size: 20px"><c:if test="${yiTotal==0}">正常</c:if><c:if test="${yiTotal==1}">轻度抑郁</c:if><c:if test="${yiTotal==2}">中度抑郁</c:if><c:if test="${yiTotal==3}">重度抑郁</c:if></label></td></div>
            </tr>
            <tr>
                <div><td><label style="font-size: 20px">焦虑症的可能性：</label></td><td> <label id="jiao" style="font-size: 20px"><c:if test="${jiaoTotal==0}">几乎没有</c:if><c:if test="${jiaoTotal==1}">偏低</c:if><c:if test="${jiaoTotal==2}">偏高</c:if></label></td></div>
            </tr>

        </table>


    </div>
</div>


<script type="text/javascript">

$("#nickName").blur(
    function (){
//失焦时检验，昵称为空警告，和原昵称一样不操作，和原昵称不一样与数据库对比，不可用就警告
        var nickName =$("#nickName").val();
        if(isEmpty(nickName)){
            $("#msg").html("用户昵称不能为空!")
            $("#btn").prop("disabled",true);
            return;
        }
        var nick='${user.nick}';
        if(nickName==nick){
            return;
        }
        $.ajax(
            {
               type:"get",
               url:"user",
               data:{
                   actionName:"checkNick",
                   nick:nickName
               },
               success:function (code){
                   console.log(code);
                   if(code==1){



                   }else{
                       $("#msg").html("改昵称已存在请重新输入！")
                       $("#btn").prop("disabled",true);
                   }
               }
            }
        );

}).focus(
    function () {
        $("#msg").html("")
        $("#btn").prop("disabled",false);
    }
);


function updateUser(){
    var nickName =$("#nickName").val();
    if(isEmpty(nickName)){
        $("#msg").html("用户昵称不能为空!")
        $("#btn").prop("disabled",true);
        return false;
    }


    return true;
}
</script>